package com.example.demo.huawei;

import java.util.Scanner;

/**
 * cpu算力问题
 */
/*
3 2
1 2 5
2 4
输出：
5 4

要求： A组选出的尽可能小
答案一定存在
初始算力肯定不同
每组算力不重复
 */
public class OD41 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[] aArr = new int[m];
        int[] bArr = new int[n];
        // 换行
        sc.nextLine();
        for (int i = 0; i < m; i++) {
            aArr[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            bArr[i] = sc.nextInt();
        }

        //System.out.println(Arrays.toString(aArr));
        //System.out.println(Arrays.toString(bArr));

        // 假设 数组都是排好序的 因为尽可能选择A中最小的呢


        for (int i = 0; i < aArr.length; i++) {
            for (int j = 0; j < bArr.length; j++) {
                if (sumArr(aArr) - aArr[i] + bArr[j] == sumArr(bArr) - bArr[j] + aArr[i]) {
                    System.out.println(aArr[i] + " " + bArr[j]);
                    return;
                }
            }
        }
    }

    private static int sumArr(int[] arr) {
        int sum = 0;
        for (int i : arr) {
            sum += i;
        }
        return sum;
    }
}
